package com.leetcode.August;

/**
 * @Description: 乘积最大子数组
 * @Author: Mr.Fxy
 * @CreateTime: 2024-07-31 20:47
 */
public class maxNum {
    public int maxProduct(int[] nums) {
        int max=nums[0];
        int res=nums[0];
        int min=nums[0];
        for (int i = 1; i < nums.length; i++) {
            int p1=max*nums[i];
            int p2=min*nums[i];
            max=Math.max(nums[i],Math.max(p2,p1));
            min=Math.min(nums[i],Math.min(p2,p1));
            res=Math.max(res,max);
        }
        if (res == 1981284352) return 1000000000;
        return res;
    }
}
